<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use App\Post;

class BlogController extends Controller
{
    /**
     * 查看所有的博文
     */
    public function index()
    {
        $posts = Post::orderBy('created_at', 'desc')->paginate(10);
        return view('blog.index')->withPosts($posts);
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function getSignle($slug)
    {
        $post = Post::where('slug', '=', $slug)->first();
        return view('blog.signle')->withPost($post);
    }

}
